package edu.qust.y22.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import edu.qust.y22.bean.Adticket;
import edu.qust.y22.bean.AdticketExample;
import edu.qust.y22.mapper.AdticketMapper;
import edu.qust.y22.service.AdticketService;

@Service
public class AdticketServiceImpl implements AdticketService{
	
	@Autowired
	private AdticketMapper adtickerMapper;

	@Override
	public List<Adticket> selectAdticketByName(String adminUserName) {
		
		AdticketExample be = new AdticketExample();
		AdticketExample.Criteria c = be.createCriteria();
		c.andAdminUserNameEqualTo(adminUserName);
		
		List<Adticket> Adtickets = this.adtickerMapper.selectByExample(be);
		
		return Adtickets;
	}

	@Override
	public boolean deleteAdticketById(int id) {
		int success = this.adtickerMapper.deleteByPrimaryKey(id);
		if(success > 0) {
			return true;
		}
		return false;
	}

	@Override
	public boolean inertAdticket(Adticket adticket) {
		int sum = this.adtickerMapper.insert(adticket);
		if(sum>0) {
			return true;
		}
		return false;
	}

}
